import request from "@/utils/request";

/**
 *获取员工的综合列表数据 (分页)
 * @param {object} query 查询参数{page：1，page：5}
 * @returns Promise
 */
export const getEmployeeListAPI = (query) => {
  return request({
    methods: "get",
    url: "/sys/user",
    params: query,
  });
};

/**删除员工
 *
 * @param {string} employeeId 员工id
 * @returns Promise
 */
export const delEmployeeAPI = (employeeId) => {
  return request({
    method: "delete",
    url: `/sys/user/${employeeId}`,
  });
};
/**
 * 新增员工单个
 * @param {object} employeeForm 员工表单
 * @returns Promise
 */
export const addEmployeeAPI = (employeeForm) => {
  return request({
    method: "post",
    url: "/sys/user",
    data: employeeForm,
  });
};
/**
 * 批量新增员工
 * @param {Array} employeeList 员工列表
 * @returns Promise
 */
export const addEmployeeBatchAPI = (employeeList) => {
  return request({
    url: "/sys/user/batch",
    method: "post",
    data: employeeList,
  });
};

/**
 * // 获取员工基本信息 (包含头像)
 * @param {string} employeeId 员工id
 * @returns  promise
 */
export const getEmployeeDetailAPI = (employeeId) => {
  return request({
    method: "get",
    url: `/sys/user/${employeeId}`,
  });
};
/**
 *编辑员工信息
 * @param {object} employeeForm 员工表单
 * @returns Promise
 */
export const updateEmployeelAPI = (employeeForm) => {
  return request({
    method: "put",
    url: `/sys/user/${employeeForm.id}`,
    data: employeeForm,
  });
};
/**
 * 给员工分配角色
 * @param {string} id 员工id
 * @param {Array} roleIds 角色id数组
 * @returns Promise
 */
export const assignRoleAPI = (id, roleIds) => {
  return request({
    url: "/sys/user/assignRoles",
    data: {
      id,
      roleIds,
    },
    method: "put",
  });
};
